knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(tidyverse)
library(here)
library(readxl)
library(gghighlight)
library(lubridate)
library(plotly)
Read in Excel file, wrangle the data
fish_noaa <- read_excel(here("data", "foss_landings.xlsx")) %>%
janitor::clean_names() %>%
mutate(across(where(is.character), tolower)) %>%
mutate(nmfs_name = str_sub(nmfs_name, end = -4)) %>%
filter(confidentiality == 'public')
fish_plot <- ggplot(data = fish_noaa,
aes(x = year, y = pounds, group = nmfs_name)) +
geom_line(aes(color = nmfs_name)) +
theme_minimal()
#make it interactive
ggplotly(fish_plot)
#highlight series based on conditions
ggplot(data = fish_noaa, aes(x = year, y = pounds, group = nmfs_name)) +
geom_line() +
gghighlight(nmfs_name == 'rockfishes') + #highlights just this group
theme_minimal()

ggplot(data = fish_noaa, aes(x = year, y = pounds, group = nmfs_name)) +
geom_line(aes(color = nmfs_name)) +
gghighlight(max(pounds) > 1e8) + #highlights groups that match this criterion
theme_minimal()

Read data from web
monrowe_wt <- read_csv('https://raw.githubusercontent.com/justinelang/esm244_w2023_lab5/master/data/MWTP_Elec_Daily.csv') %>%
janitor::clean_names()
monrowe_ts <- monrowe_wt %>%
mutate(date = lubridate::mdy(date)) %>%
mutate(record_month = lubridate::month(date)) %>%
mutate(month_name = month.abb[record_month]) %>%
mutate(month_name = fct_reorder(month_name, record_month))
ggplot(data = monrowe_ts, aes(x = month_name, y = total_kwh)) +
geom_jitter(aes(color = month_name),
show.legend = FALSE,
alpha = .5,
size = .3,
width = 0.2) +
theme_classic()
